package IC.SymbolTable;

import java.util.HashMap;
import java.util.LinkedHashMap;

import IC.Constants;
import IC.SemanticChecks.SemanticError;

public class GlobalSymbolTable extends LookupSymbolTable {

	private LinkedHashMap<String,Symbol> Classes;
	
	//C'tor
	public GlobalSymbolTable(String id) {
		super(id,id);
		Classes = new LinkedHashMap<String,Symbol>();
	}

	@Override
	public Symbol getValue(String id) {
		return Classes.get(id);
	}

	@Override
	protected HashMap<String, Symbol> getInnerHashMap(SymbolKind kind, int lineNumber) throws SemanticError {
		return Classes;
	}
	
	@Override
	public String toString() {
		String str = Title() + Constants.LINE_BREAK;
		for (Symbol symbol : Classes.values())
			str += Constants.SPACE + symbol + Constants.LINE_BREAK;	
		
		str += childrensToString();
		return str;
	}

	@Override
	public String Title() {
		return "Global Symbol Table: " + getDisplayId();
	}
}
